package cn.kgc.springcloud.web.controller;

import cn.kgc.springcloud.web.entity.Group;
import cn.kgc.springcloud.web.response.ResponseResult;
import cn.kgc.springcloud.web.service.GroupService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 课工场
 * @date 2024/7/29
 * @description
 */
@RestController
@RequestMapping("group")
public class GroupController {

    @Resource
    private GroupService groupService;

    @GetMapping
    public ResponseResult groupList(){

        return groupService.groupList();
    }


    @GetMapping("{id}")
    public Group getOneGroup(@PathVariable("id") Integer id){

        return groupService.getById(id);
    }

    @PostMapping
    public ResponseResult addGroup(@RequestBody Group group){

        groupService.save(group);
        return ResponseResult.success().data(group);
    }
}
